package errors

const None Type = 0
const (
	InvalidToken                Type = iota + 1000 // 无效的令牌。
	TokenExpired                                   // 令牌过期。
	UploadError                                    //上传失败
	EmptyParameter                                 //参数为空
	ParameterLengthExceedsLimit                    //参数长度超过限制
	EmptyVerificationCode                          //验证码为空
	VerificationCodeError                          //验证码错误
	CaptchaError                                   //验证码获取错误
	NoData                                         //未找到有效数据
	ParameterErr                                   //参数错误
	NotPermission                                  // 没有权限
	DeviceCommandFailed                            // 设备命令执行失败
	LoseReportLockFailed                           // 丢失上报锁车失败
	NoGpsSignal                                    // 无GPS信号
)

const (
	EbikeModelNotExist       Type = iota + 2000 //车辆型号不存在
	EbikeModelAlreadyExist                      //车辆型号已经存在
	EbikeModelHasVehicles                       //车辆型号有车辆
	EbikeModelNameDuplicated                    //车辆型号名称重复
	EbikeModelCreateFailed                      //创建车辆型号失败
	EbikeModelUpdateFailed                      //更新车辆型号失败
	EbikeModelDeleteFailed                      //删除车辆型号失败
	EbikeModelQueryFailed                       //查询车辆型号失败
	EbikeModelTooManyFailed                     // 太多车辆
)

const (
	EbikeNotExist      Type = iota + 2100 //车辆不存在
	EbikeAlreadyExist                     //车辆已经存在
	EbikeHasOrders                        //车辆有订单
	EbikeCreateFailed                     //创建车辆失败
	EbikeUpdateFailed                     //更新车辆失败
	EbikeDeleteFailed                     //删除车辆失败
	EbikeQueryFailed                      //查询车辆失败
	EbikeControlFailed                    //车辆操作失败
	EbikeAlreadyBound                     //车辆已绑定，请解绑后再进行操作。
	EbikeNotBound                         //车辆未绑定，请先绑定车辆再进行操作。

	EbikeShareFailed          // 车辆分享失败
	EbikeShareUserNotFoundErr // 分享用户
	EbikeAlreadyShared        // 已经分享
	EbikeNotPermission        //没有该车辆操作权限
	EbikeCannotSharedOneself  // 车辆不能分享给自己

	FrameCodeIncorrectLength // 车架号长度不正确
	SNCodeIncorrectLength    // sn号长度错误

	BatteryTypeNotExist // 电池类型不存在
	YouNotBindEbike     // 您没有绑定车辆
	YouNotInBindList    // 您不在绑定列表中

	FirmwareNotAllowedToDelete //固件不允许删除，关联了升级计划
	ErrEbikeTypeHasEbike       //
	OTAUpgradePlanConflict     // 升级计划冲突
)

const (
	FaultsCodeAlreadyExist Type = iota + 2200 // 故障码已存在
)

const (
	AreaNotFound       Type = iota + 6000 // 地区不存在
	AreaQueryFailed                       // 查询地区失败
	AreaCreateFailed                      // 地区创建失败
	AreaAlreadyExist                      //地区已经存在
	AreaNameDuplicated                    //地区名称重复
)

const (
	FileParsingFailed Type = iota + 7000 // 文件解析失败
	FileNameFormat                       // 文件名称格式不正确
	FileTypeErr                          // 文件类型错误
	FileSizeMax                          // 文件大小超出限制
	FileUploadErr                        // 文件上传失败
)

const (
	ErrStoreBindUserExist Type = iota + 8000 // 门店绑定用户已存在
)

func (t Type) String() string {
	switch t {
	case None:
		return "none"
	case InvalidToken:
		return "无效的令牌"
	case TokenExpired:
		return "令牌已过期"
	case UploadError:
		return "上传失败"
	case EmptyParameter:
		return "参数为空"
	case ParameterLengthExceedsLimit:
		return "参数长度超过限制"
	case EmptyVerificationCode:
		return "验证码为空"
	case VerificationCodeError:
		return "验证码错误"
	case CaptchaError:
		return "验证码获取失败"
	case NoData:
		return "暂无数据"
	case ParameterErr:
		return "参数错误" //参数错误
	case NotPermission:
		return "您没有操作权限"
	//--------------------------------------------------
	case DeviceCommandFailed:
		return "设备指令下发失败"
	case LoseReportLockFailed:
		return "丢失上报锁车失败"
	case NoGpsSignal:
		return "无GPS信号"
	case EbikeModelNotExist:
		return "车辆型号不存在"
	case EbikeModelAlreadyExist:
		return "车辆型号已经存在"
	case EbikeModelHasVehicles:
		return "该车辆型号下有车辆"
	case EbikeModelNameDuplicated:
		return "车辆型号名称重复"
	case EbikeModelCreateFailed:
		return "创建车辆型号失败"
	case EbikeModelUpdateFailed:
		return "更新车辆型号失败"
	case EbikeModelDeleteFailed:
		return "删除车辆型号失败"
	case EbikeModelQueryFailed:
		return "查询车辆型号失败"

	case BatteryTypeNotExist:
		return "电池类型不存在"
	//-------------------------------------------------
	case EbikeNotExist:
		return "车辆不存在"
	case EbikeAlreadyExist:
		return "车辆已经存在"
	case YouNotBindEbike:
		return "您没有绑定车辆"
	case YouNotInBindList:
		return "您不在绑定列表中"

	case EbikeHasOrders:
		return "车辆存在订单"

	case EbikeCreateFailed:
		return "创建车辆失败"
	case EbikeUpdateFailed:
		return "更新车辆失败"
	case EbikeDeleteFailed:
		return "删除车辆失败"
	case ErrEbikeTypeHasEbike:
		return "该车型下存在车辆"
	case EbikeModelTooManyFailed:
		return "车辆数超过限制"

	case EbikeQueryFailed:
		return "查询车辆失败"
	case EbikeControlFailed:
		return "车辆操作失败"
	case EbikeAlreadyBound:
		return "车辆已绑定，请解绑后再进行操作。"
	case EbikeNotBound:
		return "车辆未绑定，请先绑定车辆再进行操作。"
	case EbikeShareFailed:
		return "车辆分享失败"
	case EbikeShareUserNotFoundErr:
		return "分享的用户未注册"

	case EbikeAlreadyShared:
		return "车辆已经分享过该用户了"
	case EbikeNotPermission:
		return "没有该车辆操作权限"
	case EbikeCannotSharedOneself:
		return "车辆不能分享给自己"
	case FrameCodeIncorrectLength:
		return "车架号长度不正确"
	case SNCodeIncorrectLength:
		return "SN号长度错误"

	case FirmwareNotAllowedToDelete:
		return "固件不允许删除，关联了升级计划"
	case OTAUpgradePlanConflict:
		return "升级计划冲突"
		//----------------------------------------

	case FaultsCodeAlreadyExist:
		return "故障码已存在"

	// -------------------------------------------

	case AreaNotFound:
		return "地区不存在"
	case AreaQueryFailed:
		return "查询地区失败"
	case AreaCreateFailed:
		return "地区创建失败"
	case AreaAlreadyExist:
		return "地区已经存在"
	case AreaNameDuplicated:
		return "地区名称重复"

	//---------------------------------------

	case FileParsingFailed:
		return "文件解析失败"
	case FileNameFormat:
		return "文件名称格式不正确"
	case FileTypeErr:
		return "文件类型错误"
	case FileSizeMax:
		return "文件大小超出限制"
	case FileUploadErr:
		return "文件上传失败"

	case ErrStoreBindUserExist:
		return "门店绑定用户已存在"

	default:
		return "未知错误"
	}
}
